/**
 * 
 */
package mapper;

import java.io.IOException;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

/**
 * @author puneet
 *
 */
public class GraphMapper extends Mapper<LongWritable,Text,Text,IntWritable> {

	@Override
	protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
		String vals[] = value.toString().split("\\s");
		String nodeKey = vals[0];
		int thisNodeDistance = Integer.parseInt(vals[1].trim());
		context.write(new Text(nodeKey), new IntWritable(thisNodeDistance));
		for(int i=2;i<vals.length;i++) {
			context.write(new Text(vals[i]), new IntWritable(thisNodeDistance+1));
		}
	}


}
